<template>
	<div>
		<!-- <qqmapecho :markersite="markersite" @clicksite="clicksitefun"></qqmapecho> -->
		<searchsite @getsitemsg="getsitemsgfun"></searchsite>
	</div>
</template>

<script>
	import qqmapecho from '@/components/qqmap/echopos'
	import searchsite from '@/components/qqmap/searchsite'
	export default {
		components: {
			qqmapecho,
			searchsite
		},
		name: 'home',
		data() {
			return {
				markersite:[]
			}
		},
		methods: {
			// 显示地址
			getsitefun(){
				this.markersite=[
					{id: 1, name: "地点1", latitude:39.92609476445213, longitude: 116.38838768005371},
					{id: 2, name: "地点2", latitude: 39.90012336449448, longitude: 116.34195327758789},
					{id: 2, name: "地点2", latitude: 39.90196703314077, longitude: 116.4276123046875}
				]
			},
			clicksitefun(sitemsg){
				let lat = sitemsg.latLng.lat;
				let lng = sitemsg.latLng.lng;
				let acsite = {}
				this.markersite.forEach((item,index)=>{
					if(item.latitude == lat && item.longitude == lng){
						acsite = item
					}
				})
				alert('点击了'+acsite.name)
				// this.$Message.error(`你点击的位置：${lonlat.lat}`);
			},
			// ------搜索地址部分
			getsitemsgfun(item){
				console.log(item)
			}
		},
		mounted() {
			this.getsitefun()
		},
		
	}
</script>

<style lang="less">
	#container {
		width: 800px;
		height: 500px;
	}
</style>